package org.zsk.cs.aop.service;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author zsk
 * 2021/3/8 上午11:13
 */
@Aspect
@Component
@Slf4j
public class ParamAspect {

    @Pointcut("execution(public * org.zsk.cs.aop.service.*.*(..))")
    public void doOperation() {}


    @Before("doOperation()")
    public void before(JoinPoint joinPoint) throws Throwable {
        Object[] objs = joinPoint.getArgs();
        for (Object obj : objs) {

            System.out.println("前置通知接受的参数:" + obj);

        }
    }


    @AfterReturning(returning = "object", pointcut = "doOperation()")
    public void doAfterReturning(Object object) {

        System.out.println("后置通知响应的参数:" + object);
    }


}

